<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        // 如果返回的对象、或类中 有then 方法的实现，这个类或对象会被封装为一个Promise对象
        class MyPromise {
           
            then(resolve, reject) {
                resolve('成功')
            }
        }
       
        new Promise((resolve, reject) => {
            resolve()
        }).then(value => {
            // return new MyPromise()
            return {
                then(resolve, reject) {
                    reject('失败')
                }
            }
        }).then(value => {
            console.log(value)
        },reason=>console.log(reason))
      
    </script>
</body>

</html>